From bb67a06bd6eb200694b41513d1213367364fe7d4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 16 Dec 2015 12:27:53 -0500 Subject: [PATCH] check button: Deprecate and ignore ::indicator-spacing This can be done just as well with CSS margins, so do that instead for Adwaita. --- gtk/gtkcheckbutton.c | 34 +++++++++++------------- gtk/theme/Adwaita/_common.scss | 8 ++++++ gtk/theme/Adwaita/gtk-contained-dark.css | 5 ++++ gtk/theme/Adwaita/gtk-contained.css | 5 ++++ 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 471543aa59..4d875e33b9 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -223,6 +223,15 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) G_MAXINT, INDICATOR_SIZE, GTK_PARAM_READABLE)); + + /** + * GtkCheckButton:indicator-spacing: + * + * The spacing around the indicator. + * + * Deprecated: 3.20: Use CSS margins of the indicator node, + * the value of this style property is ignored. + */ gtk_widget_class_install_style_property (widget_class, g_param_spec_int ("indicator-spacing", P_("Indicator Spacing"), @@ -230,7 +239,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) 0, G_MAXINT, INDICATOR_SPACING, - GTK_PARAM_READABLE)); + GTK_PARAM_READABLE|G_PARAM_DEPRECATED)); gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_CHECK_BOX); gtk_widget_class_set_css_name (widget_class, "checkbutton"); @@ -441,19 +450,14 @@ gtk_check_button_measure (GtkCssGadget *gadget, if (child && gtk_widget_get_visible (child)) { gint child_min, child_nat; - gint spacing; - - gtk_widget_style_get (widget, - "indicator-spacing", &spacing, - NULL); _gtk_widget_get_preferred_size_for_size (child, GTK_ORIENTATION_HORIZONTAL, for_size, &child_min, &child_nat, NULL, NULL); - *minimum = check_min + 2 * spacing + child_min; - *natural = check_nat + 2 * spacing + child_nat; + *minimum = check_min + child_min; + *natural = check_nat + child_nat; } else { @@ -680,7 +684,6 @@ gtk_check_button_allocate (GtkCssGadget *gadget, GtkWidget *child; gint check_min_width, check_nat_width; gint check_min_height, check_nat_height; - gint spacing; GdkRectangle check_clip; widget = gtk_css_gadget_get_owner (gadget); @@ -707,18 +710,13 @@ gtk_check_button_allocate (GtkCssGadget *gadget, -1, &check_min_height, &check_nat_height, NULL, NULL); - gtk_widget_style_get (widget, - "indicator-spacing", &spacing, - NULL); child = gtk_bin_get_child (GTK_BIN (button)); - if (!child || !gtk_widget_get_visible (child)) - spacing = 0; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - child_allocation.x = allocation->x + spacing; + child_allocation.x = allocation->x; else - child_allocation.x = allocation->x + allocation->width - check_nat_width - spacing; + child_allocation.x = allocation->x + allocation->width - check_nat_width; child_allocation.y = allocation->y + (allocation->height - check_nat_height) / 2; child_allocation.width = check_nat_width; child_allocation.height = check_nat_height; @@ -731,11 +729,11 @@ gtk_check_button_allocate (GtkCssGadget *gadget, if (child && gtk_widget_get_visible (child)) { if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) - child_allocation.x = allocation->x + 2 * spacing + check_nat_width; + child_allocation.x = allocation->x + check_nat_width; else child_allocation.x = allocation->x; child_allocation.y = allocation->y; - child_allocation.width = allocation->width - check_nat_width - 2 * spacing; + child_allocation.width = allocation->width - check_nat_width; child_allocation.height = allocation->height; gtk_widget_size_allocate_with_baseline (child, &child_allocation, baseline); diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 34c6101854..81aa7f2ad7 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -2140,6 +2140,14 @@ checkbutton.text-button, radiobutton.text-button { } } +radiobutton radio, +checkbutton check { + margin: 0 2px 0 2px; + &:only-child { + margin: 0; + } +} + /************ * GtkScale * ************/ diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css index e60a047bda..4ac01b1ed4 100644 --- a/gtk/theme/Adwaita/gtk-contained-dark.css +++ b/gtk/theme/Adwaita/gtk-contained-dark.css @@ -2983,6 +2983,11 @@ checkbutton.text-button, radiobutton.text-button { checkbutton.text-button:insensitive:backdrop, checkbutton.text-button:insensitive:active:backdrop, checkbutton.text-button:insensitive:inconsistent:backdrop, radiobutton.text-button:insensitive:backdrop, radiobutton.text-button:insensitive:active:backdrop, radiobutton.text-button:insensitive:inconsistent:backdrop { color: #5d6767; } +checkbutton check { + margin: 0 2px 0 2px; } + checkbutton check:only-child { + margin: 0; } + /************ * GtkScale * ************/ diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css index d9d59727a9..94fadd4c25 100644 --- a/gtk/theme/Adwaita/gtk-contained.css +++ b/gtk/theme/Adwaita/gtk-contained.css @@ -3145,6 +3145,11 @@ checkbutton.text-button, radiobutton.text-button { checkbutton.text-button:insensitive:backdrop, checkbutton.text-button:insensitive:active:backdrop, checkbutton.text-button:insensitive:inconsistent:backdrop, radiobutton.text-button:insensitive:backdrop, radiobutton.text-button:insensitive:active:backdrop, radiobutton.text-button:insensitive:inconsistent:backdrop { color: #c3c3c0; } +checkbutton check { + margin: 0 2px 0 2px; } + checkbutton check:only-child { + margin: 0; } + /************ * GtkScale * ************/ -- 2.30.2